<template>
	<view class="newsList">
		<view class="newsItem" v-for="item in news" :key="item.id" @click="navigator(item.id)">
			<image :src="item.img"></image>
			<view class="right">
				<view class="tit">{{item.title}}</view>
				<view class="info">
					<u-icon name="calendar"></u-icon><text>{{item.times}}</text>
					<u-icon name="eye"></u-icon> <text>{{item.hit}}</text>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		props:['news'],
		filters:{
			formatDate(date){
				const nDate = new Date(date)
				const year = nDate.getFullYear()
				const month = nDate.getMonth().toString().padStart(2,0)
				const day = nDate.getDay().toString().padStart(2,0)
				return year + '-' + month + '-' + day
				
			}
		},
		methods:{
			navigator(id){
				this.$emit('itemClick',id)
			}
		}
	}
</script>

<style lang="scss">
.newsList{
	.newsItem{
		background-color: #fff;
		border-radius: 20rpx;
		margin:10rpx 20rpx;
		padding:20rpx 20rpx;
		display:flex;
		image{
			max-width:200rpx;
			min-width:200rpx;
			height:150rpx;
			border: 1rpx solid #eee;
			border-radius: 10rpx;
			}
		.right{
			margin-left:15rpx;
			display: flex;
			flex-direction: column;
			justify-content: space-between;
			.tit{
				font-size: 33rpx;
			}
			.info{
				font-size: 24rpx;
				color: #999;
				display:flex;
				text-align: left;
				
				text:nth-child(2){
					margin-right: 30rpx;
				}
			}
		}
	}
}
</style>